<?php

Yii::import('application.models._base.BaseBidHistory');


class BidHistory extends BaseBidHistory
{
	private $_tablename ='bid_history_user_1';

	public function __construct($tablename = false,$scenario='insert')
	{
		if($tablename){
			$this->_tablename = $tablename;
		}		
		return parent::__construct($scenario);
	}

	public static function model($className=__CLASS__) {
		return parent::model($className);
	}

	public function tableName() {
		return $this->_tablename;
	}

	public function relations()
	{
		return array(
			'AuctionInfo'=>array(self::HAS_ONE,'AuctionInfo','','on' => 't.auction_id = auction_info.id'),
		);
	}

	public function setTableName($tablename){
		$this->_tablename = $tablename;
	}
    
	/**
	 * 获取bidding history信息
	 */
	public static function getTitle($data){
	    $title="";
	    if (!empty($data->auction_id)){
	        $title=AuctionInfo::getTitle($data->auction_id);
	    }else{
	        $title=$data->bid_source_type;
	    }
	    return $title;
	}
	
	public function search_my(){
		$criteria = new CDbCriteria;
		$criteria->addCondition('customer_id='.yii::app()->user->id);
		$criteria->order="t.created desc";
		return  $a=new CActiveDataProvider($this, array(
				'criteria' => $criteria,
				'pagination'=>array(
						'pageSize'=>25, //当前页数显示记录条数
				),
	
		));
	}	
}